package com.aegis.manage.controller.gateway;

import com.aegis.common.mybatis.model.PageResult;
import com.aegis.manage.api.request.AddApiRequest;
import com.aegis.manage.api.request.QueryApiPageRequest;
import com.aegis.manage.api.request.UpdateApiRequest;
import com.aegis.manage.api.vo.ApiInfoVO;
import com.aegis.manage.service.auth.app.AuthAppPermissionService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author wuweixin
 * 
 * @Version 1.0
 * @Descritube
 */
@RestController
@RequestMapping("/gateway/api")
@Api(tags = "网关-接口池管理")
public class GatewayApiPoolController {

    @Autowired
    private AuthAppPermissionService authAppPermissionService;


    /**
     * 查询接口分页
     *
     * @param request
     * @return
     */
    @GetMapping("/page")
    public PageResult<ApiInfoVO> queryApiPage(@Validated QueryApiPageRequest request) {
        return authAppPermissionService.queryApiPage(request);
    }


    /**
     * 创建接口
     *
     * @param request
     */
    @PostMapping("/create")
    public void createApi(@RequestBody @Validated AddApiRequest request) {
        authAppPermissionService.insertApi(request);
    }


    /**
     * 更新api
     * @param request
     */
    @PutMapping("/update")
    public void updateApi(@RequestBody @Validated UpdateApiRequest request) {
        authAppPermissionService.updateApi(request);
    }


    /**
     * 删除api
     *
     * @param id
     */
    @DeleteMapping("/del")
    public void delApi(@RequestParam("id") String id) {
        authAppPermissionService.delApi(id);
    }

}
